<!DOCTYPE html>
<html lang="{{ .Site.LanguageCode }}">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    {{ if eq .RelPermalink "/" }}
    <title>{{ .Site.Title }}</title>
    <meta property="og:title" content="{{ .Site.Title }}">
    <meta property="og:type" content="website">
    {{ else }}
    <title>{{ .Title }}{{ with .Params.subtitle }} - {{ . }} {{ end }} - {{ .Site.Title }}</title>
    <meta property="og:title" content="{{ .Title }} - {{ .Site.Title }}">
    {{ end }}
    <meta name="twitter:card" content="summary">

    {{ with .Description }}
      {{ $.Scratch.Set "summary" (markdownify .) }}
    {{ else }}
      {{ $.Scratch.Set "summary" ((delimit (findRE "(<p.*?>(.|\n)*?</p>\\s*)+" .Content) "[&hellip;] ") | plainify | truncate (default 200 .Site.Params.summary_length) (default " &hellip;" .Site.Params.text.truncated)) }}
    {{ end }}

    {{ if eq .RelPermalink "/" }}
    <meta property="description" content="{{ .Site.Params.description }}">
    {{ else }}
      {{ with ($.Scratch.Get "summary") }}
      <meta property="description" content="{{ . }}">
      <meta property="og:description" content="{{ . }}">
      {{ end }}
    {{ end }}

    {{ range (findRE "<img src=\"https?://[^\"]+" .Content 1) }}
    {{ $.Scratch.Set "autoImage" true }}
    <meta name="twitter:image" content="{{ replaceRE "<img src=\"" "" . | htmlUnescape }}">
    {{ end }}
    {{ with .Site.Params.twitterImage }}
    {{ if not ($.Scratch.Get "autoImage") }}
    <meta name="twitter:image" content="{{ absURL . }}">
    {{ end }}
    {{ end }}

    {{ if .Keywords }}
    <meta property="keywords" content ="{{ delimit .Keywords ", " }}">
    {{ end }}

    {{ with .OutputFormats.Get "RSS" }}
    <link href="{{ .RelPermalink }}" rel="alternate" type="application/rss+xml" title="{{ $.Site.Title }}" />
    {{ end }}
    {{ partial "head_highlightjs" . }}
    <link rel="stylesheet" href="{{ "/css/style.css" | relURL }}" />
    <link rel="stylesheet" href="{{ "/css/fonts.css" | relURL }}" />
    {{ partial "head_custom.html" . }}
  </head>

  {{ $.Scratch.Set "section" (replaceRE "^/([^/]+)/.*" "$1" .RelPermalink) }}
  <body class="{{ if .IsHome }}home{{ else }}{{ $.Scratch.Get "section" }}{{ end }}">
    <div id="pjax-content">
    <header class="masthead">
      {{ partial "tagline.html" . }}
      {{ partial "menu.html" . }}
    </header>
    <article class="main">
      <header class="title">
      {{ partial "meta.html" . }}
      </header>
